package com.scse.bms.util;

import cn.hutool.core.util.ObjectUtil;
import com.scse.bms.domain.ThemeVO;
import com.scse.bms.domain.UserVO;
import com.scse.bms.entity.HistoryDO;
import com.scse.bms.entity.ThemeDO;
import com.scse.bms.entity.UserDO;
import io.swagger.models.auth.In;

/**
 * @Title: HistoryUtil
 * @Author: 吴赠禹
 * @Date: 2021/2/24 7:21
 * @Version: 1.0
 * @Description: TODO
 */
public class HistoryUtil {


    /**
     * 返回历史对象
     * @param user 判空
     * @param bookId
     * @param theme 判空
     * @return
     */
    public static HistoryDO generateHistory(UserVO user, Integer bookId, ThemeVO theme) {
        HistoryDO history = new HistoryDO();
        history.setBookId(bookId);
        if (ObjectUtil.isNotNull(user)) {
            history.setUserId(user.getId());
        }
        if (ObjectUtil.isNotNull(theme)) {
            history.setThemeId(theme.getId());
        }
        return history;
    }
}
